package com.bw.common.adapter

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bw.image.imageUtils.glide.GlideImgLoader

/**
 * 定义DataBinding的绑定适配器
 * 注意事项：必须开启DataBinding
 * dataBinding {
 *    enabled = true
 * }
 */
object CommonBindingAdapter {

    @JvmStatic
    @BindingAdapter("loadResImage")
    fun loadResImage(iv: ImageView, resId: Int){
        if (resId != 0){
            GlideImgLoader.loadResImage(iv, resId, iv)
        }
    }

    @JvmStatic
    @BindingAdapter("loadUrlImage")
    fun loadUrlImage(iv: ImageView, url: String){
        if (!url.isNullOrEmpty()){
            GlideImgLoader.loadImage(iv.context, url, iv)
        }
    }



}